import Vue from 'vue'
import App from './App'
import uView from "uview-ui"
import store from './store'
import config from '@/app.config.js'
Vue.use(uView);

// 引入 vk框架前端
import vk from './uni_modules/vk-unicloud';
Vue.config.productionTip = false



Vue.use(vk);

// 初始化 vk框架
Vue.prototype.vk.init({
  Vue,               // Vue实例
  config,	           // 配置
});

App.mpType = 'app'


Vue.prototype.baseUrl = process.env.NODE_ENV !== 'production'?'http://8.134.36.138/api':'http://8.134.36.138/api',

// Vue.prototype.$getUser = ()=>{
// 	return uni.getStorageSync("USERDATA");
// }
// Vue.prototype.$setUser = (userData)=>{
// 	uni.setStorageSync("USERDATA",userData)
// }
// Vue.prototype.$delUser = ()=>{
// 	uni.removeStorageSync("USERDATA")
// }
// Vue.prototype.$setKey = (key,value)=>{
// 	uni.setStorageSync(key,value);
// }
// Vue.prototype.$getKey = (key)=>{
// 	return uni.getStorageSync(key);
// }

// 设置持久化封装
Vue.prototype.$setLogin = (key)=>{
	let {uid,token, tokenExpired,avatar,userInfo} =  key
	uni.setStorageSync('uid',uid)
	uni.setStorageSync('uni_id_token', token)
	uni.setStorageSync('uni_id_token_expired', tokenExpired)
	uni.setStorageSync('avatar_url',avatar)
	Vue.prototype.$setUser({
		userinfo:userInfo
	})
}

// 删除持久化封装
Vue.prototype.$delLogin = ()=>{
	uni.removeStorageSync('uid')
	uni.removeStorageSync('uni_id_token')
	uni.removeStorageSync('uni_id_token_expired')
	uni.removeStorageSync('avatar_url')
	Vue.prototype.$delUser()
}


const app = new Vue({
	store,
    ...App
})
app.$mount()
